<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      const a = "user" + "name";
      const obj = {
        a: 1,
        b: 2,
        get c() {
          // 获取
          return this.a + this.b;
        },
        set c(value) {
          this.a = value / 2;
          this.b = value - this.a;
        },
        // username: "jack",
        ["user" + "name"]: "jack",
      };
      console.log(obj.c); // obj.get c()
      obj.c = 10; // obj.set c(10)
      console.log(obj.c); // obj.get c()
    </script>
  </body>
</html>
